package tom.jiafei;
import java.sql.*;
public class Update{
	public boolean update(String updateCondition) {

		boolean  x=false;
		Connection con;
	    Statement sql;
	   try{
	    	Class.forName("com.mysql.jdbc.Driver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:mysql://127.0.0.1:3306/book_store?useUnicode=true&characterEncoding=utf8";
		String user = "root";
		String password = "1e916d4e2405be9e";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(updateCondition);
		if(m!=0){
			x=true;			
		}
		con.close();
	}
	catch(SQLException e1){x=false;}
    return x;
	}
	public boolean update_(String table,String propety,String value,String userid) {
		try{
			byte a[]=value.getBytes("ISO-8859-1");
            value=new String(a);}
        catch(Exception e){
        }
        String updateCondition="update "+table+" set "+propety+"='"+value+"' where userid='"+userid+"'";
		boolean  x=false;
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.mysql.jdbc.Driver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:mysql://127.0.0.1:3306/book_store?useUnicode=true&characterEncoding=utf8";
		String user = "root";
		String password = "1e916d4e2405be9e";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(updateCondition);
		if(m!=0){
			x=true;			
		}
		con.close();
	}
	catch(SQLException e1){x=false;}
    return x;
	}
}